y=eval(input())
m=eval(input())
d=eval(input())
if (y%400==0) or (y%100!=0 and y%4==0):
    if m==2:
        print(29-d)
    elif m in(1,3,5,7,8,10,12):
        print(31-d)
    elif m in(4,6,9,11):
        print(30-d)
else:
    if m==2:
        print(28-d)
    elif m in(1,3,5,7,8,10,12):
        print(31-d)
    elif m in(4,6,9,11):
        print(30-d)